<?php
# Datos personales
$disabled = (isset($datospersonales_editable) && $datospersonales_editable == 0 ? " disabled" : "");

echo "<table id=\"tablaDatospersonales\" cellspacing=\"0\" cellpadding=\"0\" class=\"formTable\">\n";
echo "<tr><td class=\"tokenContent3\">\n";

echo "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">\n";
echo "<tr valign=\"top\">\n";

echo "<td width=\"60%\">\n";
echo "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" class=\"formTable\">\n";

if (isset($row_pacientes) && trim($row_pacientes->tratado_por) != "") $medres = stripslashes($row_pacientes->tratado_por);
else if (isset($_SESSION["user"]) && $_SESSION["user"] != "") $medres = $_SESSION["username"];

echo "<tr><td colspan=\"6\" style=\"padding: 0px 12px 6px 0px\" align=\"right\">\n";
echo "<b>M&eacute;dico responsable:</b> ".$medres."\n";
echo "</td></tr>\n";

echo "<tr><td colspan=\"6\" class=\"separador\">&nbsp;</td></tr>\n";

echo "<tr valign=\"top\">\n";
echo "<td colspan=\"2\" class=\"paddedTd\">Nombre<br><input type=\"text\" name=\"nombre\" class=\"textBox\" value=\"".(isset($row_pacientes) ? htmlentities(stripslashes($row_pacientes->nombre), ENT_QUOTES) : "")."\"".$disabled."></td>\n";
echo "<td colspan=\"2\" class=\"paddedTd\">Apellidos<br><input type=\"text\" name=\"apellidos\" class=\"textBox\" value=\"".(isset($row_pacientes) ? htmlentities(stripslashes($row_pacientes->apellidos), ENT_QUOTES) : "")."\"".$disabled."></td>\n";
echo "<td width=\"15%\" class=\"paddedTd\">DNI<br><input type=\"text\" name=\"dni\" class=\"textBox\" value=\"".(isset($row_pacientes) ? htmlentities(stripslashes($row_pacientes->dni), ENT_QUOTES) : "")."\"".$disabled."></td>\n";
echo "<td width=\"15%\">Sexo<br><select name=\"sexo\" class=\"comboBox\"".$disabled."><option value=\"\"></option><option value=\"H\"".(isset($row_pacientes) && $row_pacientes->sexo == "H" ? " selected" : "").">Hombre</option><option value=\"M\"".(isset($row_pacientes) && $row_pacientes->sexo == "M" ? " selected" : "").">Mujer</option></select></td>\n";
echo "</tr>\n";

echo "<tr><td style=\"height: 2px; font-size: 1px\">&nbsp;</td></tr>\n";

echo "<tr valign=\"top\">\n";
echo "<td width=\"15%\" class=\"paddedTd\">Nacimiento<br><input type=\"text\" name=\"nacimiento\" class=\"textBox\" value=\"".(isset($row_pacientes) ? htmlentities(stripslashes($row_pacientes->nacimiento), ENT_QUOTES) : "")."\"".$disabled." onblur=\"mostrarEdad(this.value, ".date("Y").");\"></td>\n";
echo "<td width=\"15%\" class=\"paddedTd\">Tel&eacute;fono 1<br><input type=\"text\" name=\"telefono1\" class=\"textBox\" value=\"".(isset($row_pacientes) ? htmlentities(stripslashes($row_pacientes->telefono1), ENT_QUOTES) : "")."\"".$disabled."></td>\n";
echo "<td width=\"15%\" class=\"paddedTd\">Tel&eacute;fono 2<br><input type=\"text\" name=\"telefono2\" class=\"textBox\" value=\"".(isset($row_pacientes) ? htmlentities(stripslashes($row_pacientes->telefono2), ENT_QUOTES) : "")."\"".$disabled."></td>\n";
echo "<td width=\"15%\" class=\"paddedTd\">C&oacute;digo postal<br><input type=\"text\" name=\"cp\" class=\"textBox\" value=\"".(isset($row_pacientes) ? htmlentities(stripslashes($row_pacientes->cp), ENT_QUOTES) : "")."\"".$disabled."></td>\n";
echo "<td colspan=\"2\">N&ordm; de p&oacute;liza<br><input type=\"text\" name=\"num_poliza\" class=\"textBox\" value=\"".(isset($row_pacientes) ? htmlentities(stripslashes($row_pacientes->num_poliza), ENT_QUOTES) : "")."\"".$disabled."></td>\n";
echo "</tr>\n";

echo "<tr><td style=\"height: 2px; font-size: 1px\">&nbsp;</td></tr>\n";

echo "<tr valign=\"top\">\n";

if (!empty($row_pacientes->nacimiento))
{
	$edad2 = date("Y") - intval($row_pacientes->nacimiento);
	$edad1 = $edad2 - 1;

	$edadstr = $edad1."-".$edad2;
}

echo "<td class=\"paddedTd\">Edad<br><input type=\"text\" name=\"edad\" class=\"textBox\" value=\"".(isset($edadstr) ? $edadstr : "")."\" disabled></td>\n";
echo "<td colspan=\"2\" class=\"paddedTd\">Compa&ntilde;&iacute;a aseguradora<br><select name=\"id_aseguradora\" class=\"comboBox\"".$disabled."><option value=\"\">";

$query = "SELECT id_aseguradora, aseguradora FROM listaaseguradoras ORDER BY aseguradora";
$q_aseguradoras = mysql_query($query, $sock);

while ($row_aseguradoras = mysql_fetch_object($q_aseguradoras))
{
	$id_aseguradora = $row_aseguradoras->id_aseguradora;
	$aseguradora = $row_aseguradoras->aseguradora;

	echo "<option value=\"".$id_aseguradora."\"".(isset($row_pacientes->id_aseguradora) && $row_pacientes->id_aseguradora == $id_aseguradora ? " selected" : "").">".$aseguradora."</option>\n";
}

echo "</select></td>\n";
echo "<td colspan=\"3\">Remitido por...<br><input type=\"text\" name=\"remitido_por\" class=\"textBox\" value=\"".(isset($row_pacientes) ? htmlentities(stripslashes($row_pacientes->remitido_por), ENT_QUOTES) : "")."\"".$disabled."></td>\n";
echo "</tr>\n";

echo "<tr><td colspan=\"6\" style=\"padding-top: 14px\">\n";
require("includes/alergias.inc.php");
require("includes/antecmedic.inc.php");
require("includes/antecquirur.inc.php");
require("includes/tratamhabit.inc.php");
echo "</td></tr>\n";

echo "</table>\n";
echo "</td>\n";

echo "<td width=\"40%\">\n";
echo "<div id=\"infoLayer1\" class=\"infoLayer\"></div>\n";
echo "</td>\n";

echo "</tr>\n";
echo "</table>\n";

echo "</td></tr></table>\n";
?>
